package com.shuoyue.ycgk.ui.main;

import com.shuoyue.ycgk.base.BasePresenter;
import com.shuoyue.ycgk.base.BaseResult;
import com.shuoyue.ycgk.base.BaseView;
import com.shuoyue.ycgk.entity.Estimate;
import com.shuoyue.ycgk.entity.MainAdv;
import com.shuoyue.ycgk.entity.UserTestPaper;
import com.shuoyue.ycgk.net.RetrofitClient;
import com.shuoyue.ycgk.net.base.ApiSubscriber;
import com.shuoyue.ycgk.net.gsondefaultadapter.Optional;
import com.shuoyue.ycgk.ui.estimate.EstimateContract;

import java.util.List;

import io.reactivex.Observable;

public interface MainAdvContract {
    interface View extends BaseView {

        void setAdv(MainAdv mainAdv);
    }

    class Presenter extends BasePresenter<View> {
        Model model = new Model();

        public void getMainAdv() {
            apply(model.getMainAdv())
                    .subscribe(new ApiSubscriber<Optional<MainAdv>>(mView, this) {
                        @Override
                        public void onNext(Optional<MainAdv> option) {
                            super.onNext(option);
                            mView.setAdv(option.getIncludeNull());
                        }
                    });
        }
    }

    class Model {
        Observable<BaseResult<MainAdv>> getMainAdv() {
            return RetrofitClient.getInstance().getApi().getMainAdv();
        }
    }
}
